package xgenerator.ui.swing.adapter;

import java.awt.Component;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class LookAndFeelAdapter extends AbstractAction {

	/**
	 * UI组件
	 */
	private Component ui;

	/**
	 * constructor
	 * @param ui
	 */
	public LookAndFeelAdapter(Component ui) {
		this.ui = ui;
	}

	/**
	 * <p>
	 * Title：actionPerformed
	 * </p>
	 * @author <a href="mailto:shushanlee@msn.com">liss</a>
	 * @param e
	 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
	 */
	public void actionPerformed(ActionEvent e) {
		try {
			UIManager.setLookAndFeel(e.getActionCommand());
		} catch (Exception ex) {
			System.out.println(e);
		}
		SwingUtilities.updateComponentTreeUI(ui);
	}

	/**
	 * <p>
	 * Title：获取ui界面
	 * </p>
	 * @author <a href="mailto:shushanlee@msn.com">liss</a>
	 * @return
	 */
	public Component getUI() {
		return ui;
	}

	/**
	 * <p>
	 * Title：设置ui界面
	 * </p>
	 * @author <a href="mailto:shushanlee@msn.com">liss</a>
	 * @param ui
	 */
	public void setUI(Component ui) {
		this.ui = ui;
	}

}
